<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>管理中心</title>
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript" src="scripts/jquery.editor.js"></script>
<script type="text/javascript">
{literal}
var e;
$(function(){
	e=$('#content_text').xheditor({
		upImgUrl:"?action=upload",
		upImgExt:"jpg,gif,png",
		onUpload:function(msg){
			msg=msg.toString().replace('uploads/','');
			$("#attachment_list").val($("#attachment_list").val()+msg+",");
		},
		shortcuts:{
			'ctrl+enter':function(){
				$('#content_info').submit();
			}
		}	
	});
});

function editor_insert(html){
	e.pasteHTML(html);
}
function editor_insert_attachment(filename){
	var ext=filename.split(".")[1];
	if(ext=='gif'||ext=='jpg'||ext=='png'||ext=='bmp'){
		editor_insert('<img src="uploads/'+filename+'" alt=""/>');
	}else{
		editor_insert('<a href="uploads/'+filename+'">'+filename+'</a>');
	}
}
function addlink(obj){
	document.getElementById('content_link').innerHTML+="<div style=\"padding:4px 0\"'><input type=\"text\" class=\"input\" name=\"content_link[]\" size=\"110\"/>&nbsp;<a href=\"javascript:;\" onclick=\"removelink(this)\">[-]</a></div>";
}
function removelink(obj){
var parent=obj.parentNode;
	parent.innerHTML='';
	parent.parentNode.removeChild(parent);
}
var attachmentnum=1;
function addattachment(obj){
  if(attachmentnum>=10)return;
document.getElementById('content_attachment').innerHTML+="<div style=\"padding:4px 0\"'><input type=\"file\" class=\"input\" name=\"content_attachment[]\" />&nbsp;<a href=\"javascript:;\" onclick=\"removeattachment(this)\">[-]</a></div>";
  attachmentnum++;
}
function removeattachment(obj){
var parent=obj.parentNode;
	parent.innerHTML='';
	parent.parentNode.removeChild(parent);
  attachmentnum--;
}
{/literal} 
</script>
</head>
<body>
<!--{include file="top.htm"}-->
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="150" valign="top"><!--{include file="left.htm"}--></td>
<td valign="top">
<div class='title'>
<a href="?action=content&do=content_list&channel_id=<!--{$smarty.request.channel_id}-->">内容列表</a>
&raquo;&nbsp;<!--{if $mode=='insert'}-->添加内容<!--{else}-->编辑内容<!--{/if}-->

</div>
<div class='item'>
<form action="?action=content&do=content_<!--{$mode}-->" method="post" enctype="multipart/form-data" name="content_info">
<input name="attachment_list" id="attachment_list" type="hidden" value=""/>
	<table width="100%">
{if $category_list!=''}
	<tr>
		<td width="100" height="30" align="right">选择分类：</td>
		<td>
			<select name="category_id">
		<option value="0">请选择...</option>{$category_list}
		</select>
</td>
		</tr>
{/if}
		<tr>
		<td width="100" height="30" align="right">标题：</td>
		<td><input type="text" name="content_title" style="width:734px" value="<!--{$content.title|escape:html}-->" class="input"/></td>
		</tr>

		<tr>
		<td valign="top" align="right">正文：</td>
		<td><textarea name="content_text" id="content_text" style="width:740px;height:300px"><!--{$content.text|escape:html}--></textarea>
		注：内容分页请使用<span style="color:red">#page#</span>分隔内容
		</td>
		</tr>


		<tr>
		<td width="100" height="30" align="right">外部连接：</td>
		<td><input type="text" name="content_url" size="80" value="<!--{$content.url|escape:html}-->" class="input"/>
		(若设置了此项则直接打开此连接)
		</td>
		</tr>


		<tr>
		<td height="30" align="right">缩图：</td>
		<td><input type="file" name="content_thumb" class="input"/>
		<!--{if  !$content.thumb_http}-->
		<!--{if $content.thumb}-->
		<a href="uploads/<!--{$content.thumb}-->" target="_blank"><img src="uploads/<!--{$content.thumb}-->" alt="" align="absmiddle" style="width:20px;height:20px;border:1px solid #ccc;padding:1px"/></a>
		<label><input type="checkbox" name="content_thumb_delete" value="<!--{$content.thumb}-->" /> 删除</label>
		<input type="hidden" name="content_thumb_old" value="<!--{$content.thumb}-->"/>
		<!--{/if}-->
		<!--{/if}-->
		</td>
		</tr>

		<tr>
		<td height="30">&nbsp;</td>
		<td>
		<input type="text" name="content_thumb_http" size="110" value="<!--{$content.thumb_http}-->" class="input"/>
		</td>
		</tr>


		<tr>
		<td height="30" valign="top" align="right">附件：</td>
		<td>
				<!--{foreach from=$content.attachment item=attachment}-->
			<div style="padding:4px 0"><input type="checkbox" name="content_attachment_delete[]" value="{$attachment.id}" />&nbsp;<a href="uploads/{$attachment.name}" target="_blank">{$attachment.name}</a>&nbsp<a href="javascript:;" onclick="editor_insert_attachment('{$attachment.name}');">[+]</a></div>
			<!--{/foreach}-->
			<input type="file" name="content_attachment[]" class="input"/>&nbsp;<a href="javascript:;" onclick="addattachment(this)">[+]</a>
			<div id="content_attachment"></div>
		</td>
		</tr>


		<tr>
		<td width="100" height="30" valign="top" align="right">链接：</td>
		<td>
		<input type="hidden" name="content_link_count" value="<!--{foreach from=$content.link item=link name=content_link_count}--><!--{$link.id}--><!--{if !$smarty.foreach.content_link_count.last}-->,<!--{/if}--><!--{/foreach}-->" />
			<!--{foreach from=$content.link item=link}-->
			<div style="padding:4px 0">
				<input type="text" name="content_link_{$link.id}" value="{$link.url}" class="input" size="110" />
				<label>
				<input type="checkbox" name="content_link_delete[]" value="{$link.id}" />
				删除
				</label>
				</div>
			<!--{/foreach}-->
			<input type="text" name="content_link[]" size="110" class="input"/>&nbsp;<a href="javascript:;" onclick="addlink(this)">[+]</a>
			<div id="content_link"></div>
		</td>
		</tr>
		<tr>
		<td width="100" height="30" align="right">关键字：</td>
		<td><input type="text" name="content_keywords" size="40" value="<!--{$content.keywords|escape:html}-->" class="input"/></td>
		</tr>
		<tr>
		<td width="100" height="30" align="right">描述：</td>
		<td><textarea name="content_description" class="input" rows="4" cols="80"><!--{$content.description|escape:html}--></textarea></td>
		</tr>
		<tr>
		<td height="30" align="right">密码：</td>
		<td><input type="text" name="content_password" size="40" value="<!--{$content.password}-->" class="input"/></td>
		</tr>
		<tr>
		<td height="30" align="right">属性：</td>
		<td>
<label><input type="checkbox" name="content_is_best" value="1" {if $content.is_best==1}checked{/if} />推荐</label>
<label><input type="checkbox" name="content_is_comment" value="1" {if $content.is_comment==1}checked{/if} />评论</label>
<label><input type="checkbox" name="content_state" value="1" {if $content.state==1}checked{/if} /> 显示</label>
		</td>
		</tr>
		<input type="hidden" name="content_id" value="<!--{$content.id}-->"/>
		<input type="hidden" name="channel_id" value="<!--{$content.channel_id}-->"/>	
		<tr>
		<td width="100" height="30">&nbsp;</td>
		<td><input type="submit" value="提交" class="button"/></td>
		</tr>
	</table>
	
</form>
</div>
</td>
</tr>
</table>
</body>
</html>